package org.store.domain;

public class Product extends Identified {
    private final String title;
    private final long price; // (cents)
    private final int amount;
    private final long imageId;
    private final long categoryId;

    public Product(String title, long price, int amount, long imageId, long categoryId) {
        this.title = title;
        this.price = price;
        this.amount = amount;
        this.imageId = imageId;
        this.categoryId = categoryId;
    }

    public long getImageId() {
        return imageId;
    }

    public String getTitle() {

        return title;
    }

    public long getPrice() {
        return price;
    }

    public int getAmount() {
        return amount;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Product)) return false;
        if (!super.equals(o)) return false;

        Product product = (Product) o;

        if (amount != product.amount) return false;
        if (categoryId != product.categoryId) return false;
        if (imageId != product.imageId) return false;
        if (price != product.price) return false;
        if (title != null ? !title.equals(product.title) : product.title != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + (title != null ? title.hashCode() : 0);
        result = 31 * result + (int) (price ^ (price >>> 32));
        result = 31 * result + amount;
        result = 31 * result + (int) (imageId ^ (imageId >>> 32));
        result = 31 * result + (int) (categoryId ^ (categoryId >>> 32));
        return result;
    }

    public Long getCategoryId() {
        return categoryId;
    }
}
